package team.xiaobaiya.gptchatrobot.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import team.xiaobaiya.gptchatrobot.util.Resp;

/**
 * @ClassName ControllerExceptionListener
 * @Author Feng Yingnan
 * @Email fengyn1211@163.com
 * @Date 2023/4/7 9:37
 */
@Slf4j
@ControllerAdvice
public class ControllerExceptionListener {

    @ExceptionHandler(value = AbstractDirectRespException.class)
    public Resp exceptionHandler(AbstractDirectRespException exception) {
        log.error(exception.getMessage());
        exception.printStackTrace();
        return exception.resp();
    }

}
